<?php
/**
 * User: papa
 * Date: 18/5/22
 * Time: 11:34
 */

namespace app\api\validate;


use app\api\lib\exception\ParamException;

class OrderPlace extends BaseValidate
{
    //下单验证器
    protected  $rule = [
        'price' => 'require|isFloatOrpositive',
        'coupon_id' => 'isPositiveInteger',
//        'points' => 'isPositiveInteger',
//        'type' => 'require|isPositiveInteger',
//        'table' => 'isPositiveInteger|requireIf:type,1',
        'phone' =>['regex'=>'/^((\+?86)|(\(\+86\)))?\d{3,4}-\d{7,8}(-\d{3,4})?$|^((\+?86)|(\(\+86\)))?1\d{10}$/'],
        'address' => 'require',
        'name' => 'require',
        'food' => 'checkFood',
    ];

    protected $message = [
        'price.price' => '金额必须存在',
        'price.isFloatOrpositive' => '输入金额不正确',
        'coupon_id.isPositiveInteger' => '输入金额不正确',
//        'points.isPositiveInteger' => '参数错误',
//        'type.require' => '必须选择用餐类型',
//        'type.isPositiveInteger' => '参数错误',
//        'table.isPositiveInteger' => '桌号填写错误',
//        'table.requireIf' => '堂食时，请输入桌号',
        'phone' => '联系方式错误',
        'address.requireIf' => '收件地址必须填写',
        'name.requireIf' => '收件人名称必须填写',
    ];

    //菜品的验证
    protected $singleRule = [
        'food_id' => 'require|isPositiveInteger',
        'count' => 'require|isPositiveInteger',
    ];


}